/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ourpkr.model.joueur;

import java.beans.PropertyChangeSupport;
import java.util.Vector;
import ourpkr.OurPkrApp;

/**
 *
 * @author niboucha
 */
public class IA extends Joueur{
   
    public IA(String nom, int nb)
    {
        pcs = new PropertyChangeSupport(this);
        this.nom = nom;
        this.number = nb;
    }
    
    public synchronized int joue(){
        setPlaying(true);
        try{//Pour donner l'impression qu'il reflechit
            Thread.sleep(500*Math.round(Math.random()*10));
        }
        catch(Exception e){}
        double rnd = Math.random() * 3;
        if(rnd < 1){
                setWhatToDo(-1) ;
        } 
        else if(rnd < 2 && (fortune + getMiseCourante() - miseMiniTour()) >= 0){
            setWhatToDo(0);
        }
        else if(fortune + getMiseCourante() - 2 * miseMiniTour() >= 0){
            setWhatToDo(2*miseMiniTour());
        }
        else{
            setWhatToDo(-1);
        }
        setPlaying(false);
        return getWhatToDo();
    }

}
